import React from 'react'
import PropTypes from 'prop-types'
import {connect} from './woniu-react-redux';
import {Map,is} from 'immutable'
import {createSelector} from 'reselect'
import {addGun,removeGun,addGunAsync,addGun2,addGunTwice} from './index_redux'
const numSelector =createSelector(
    state=>state,
    state=>({num:state*2})
)
// import test from './test'
// import {addGun} from './index_redux.js'
// App=connect(mapStateToProps,actionCreators,)(App)
// let obj=Map({
//     'name':'imooc',
//     'course':Map({
//         'name':'react-redux'
//     })
// })
// let obj1=obj.set('name','sb')
// console.log(obj1===obj)
// console.log(obj.get('course')===obj1.get('course'))

let obj=Map({name:1,title:'imooc'})
let obj1=Map({name:1,title:'imooc'})
console.log(is(obj,obj1))
@connect(
    //你要state什么属性放到props
    state=>numSelector(state),
    //你要什么方法放到props 自动dispatch
    {addGun,removeGun,addGunAsync,addGun2,addGunTwice}
)
class App extends React.Component{
    render(){
        console.log(this.props.addGun)
        return (
            <div>
                <button onClick={this.props.addGun}>申请武器</button>
                <button onClick={this.props.addGunTwice}>申请二次武器</button>

                <button onClick={()=>{this.props.addGun2(2)}}>申请武器2</button>

                <button onClick={this.props.removeGun}>回收武器</button>
                <button onClick={this.props.addGunAsync}>托两天再给</button>
                <h1>现在有机枪{this.props.num}把</h1>
            </div>
            
        )
    }

}
// App=connect(
//     state=>({num:state}), {addGun,removeGun,addGunAsync}
//     )(App)
export default App